<template>
  <div class="container">
    <div class="download-section">
      <h2>APP下载</h2>
      <div class="download-content">
        <div class="contact-info">
          <div class="contact-row">
            <span>客服Q: <span class="contact-value">452053404</span></span>
            <button class="copy-btn" @click="copyToClipboard('452053404')">复制</button>
          </div>
          <div class="contact-row">
            <span>客服V: <span class="contact-value">lee22633</span></span>
            <button class="copy-btn" @click="copyToClipboard('lee22633')">复制</button>
          </div>
          <div class="contact-row">
            <span>QQ群: <span class="contact-value">637234008</span></span>
            <button class="copy-btn" @click="copyToClipboard('637234008')">复制</button>
          </div>
        </div>
        <div v-if="isIOS" class="ios-download">
          <img src="/imgs/qr_app_ios.png" alt="iOS下载二维码" class="qr-code">
          <p>请使用Safari浏览器扫描二维码下载</p>
          <a :href="iosDownloadUrl" class="download-btn">直接下载</a>
        </div>
        <div v-else class="android-download">
          <img src="/imgs/qr_app_android.png" alt="Android下载二维码" class="qr-code">
          <p>请使用浏览器扫描二维码下载</p>
          <a :href="androidDownloadUrl" class="download-btn">直接下载</a>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'AppDownload'
}
</script>

<script setup>
import { ref, onMounted } from 'vue'

const isIOS = ref(false)
const iosDownloadUrl = ref('https://vip.123pan.cn/1833927958/link/app/ios/fy168.mobileconfig')
const androidDownloadUrl = ref('https://vip.123pan.cn/1833927958/link/app/android/fy168.apk')

function copyToClipboard(text) {
  const textarea = document.createElement('textarea')
  textarea.value = text
  document.body.appendChild(textarea)
  textarea.select()
  document.execCommand('copy')
  document.body.removeChild(textarea)
}

onMounted(() => {
  // 检测设备类型
  const userAgent = navigator.userAgent.toLowerCase()
  isIOS.value = /iphone|ipad|ipod/.test(userAgent)
})
</script>

<style scoped>
.container {
  width: 100%;
  margin: 0 auto;
  padding: 20px;
  min-height: 90vh;
  background-color: #f7f7f7;
  box-sizing: border-box;
}

.download-section {
  max-width: 100%;
  background: #fff;
  border-radius: 8px;
  padding: 20px;
  text-align: center;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

.download-section h2 {
  margin: 0 0 20px;
  color: #333;
  font-size: 24px;
}

.download-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.qr-code {
  width: 200px;
  height: 200px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.download-content p {
  color: #666;
  margin: 10px 0;
}

.download-btn {
  display: inline-block;
  padding: 12px 24px;
  background-color: #409EFF;
  color: white;
  text-decoration: none;
  border-radius: 4px;
  font-size: 16px;
  transition: background-color 0.3s;
}

.download-btn:hover {
  background-color: #66b1ff;
}

.contact-info {
  width: 100%;
  margin-bottom: 10px;
}
.contact-row {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
  gap: 8px;
}
.contact-value {
  font-weight: bold;
  color: #333;
}
.copy-btn {
  padding: 4px 10px;
  font-size: 14px;
  background: #e6e6e6;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  margin-left: 6px;
  transition: background 0.2s;
}
.copy-btn:hover {
  background: #d0d0d0;
}

@media (max-width: 600px) {
  .container {
    padding: 10px;
  }

  .download-section {
    padding: 15px;
  }

  .qr-code {
    width: 150px;
    height: 150px;
  }

  .download-section h2 {
    font-size: 20px;
  }
}
</style> 